<template xmlns="http://www.w3.org/1999/html">
    <!--新建-->
    <smart-form ref="form_create" method="POST" url="/sys/user/info"
                v-show="operation==='new'" :model="form_data">
      <smart-form-layout require hidden name="account" label="账户">
        <smart-text-view name="account" placeholder="账户" value="med"></smart-text-view>
      </smart-form-layout>
      <smart-form-layout require name="gender" label="性别">
        <smart-select name="gender" placeholder="性别" options="non.user_gender"></smart-select>
      </smart-form-layout>
      <smart-form-layout require name="username" label="昵称">
        <smart-text-view name="username" placeholder="昵称"></smart-text-view>
      </smart-form-layout>
      <smart-form-layout require name="phone" label="手机">
        <smart-text-view name="phone" placeholder="手机"></smart-text-view>
      </smart-form-layout>
    </smart-form>
</template>

<script>

export default {
    props: {
        // 成功回调，通常是刷新数据表格
        onSucceed: {type: Function, default: undefined}
    },
    data() {
        return {
            // 是否展开弹出层
            expend: false,
            // 当前操作的数据
            row_data: undefined,
            // 操作名称
            operation: undefined,
            // 弹窗名称
            title: '',
            //表单附带信息
            attach: {},
            // form-data start 表单数据对象模型
            form_data: [
                {
                    name: 'id', label: 'ID', value: ''
                    , rules: [
                        {required: true, message: '[ID]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 32, message: '最多32字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'account', label: '账户', value: ''
                    , rules: [
                        {required: true, message: '[账户]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 32, message: '最多32字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'no', label: '工号', value: ''
                    , rules: [
                        {required: true, message: '[工号]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 16, message: '最多16字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'motto', label: '座右铭', value: ''
                    , rules: [
                        {required: true, message: '[座右铭]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 128, message: '最多128字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'status', label: '用户状态', value: ''
                },
                {
                    name: 'gender', label: '性别', value: ''
                },
                {
                    name: 'portrait', label: '用户头像', value: ''
                    , rules: [
                        {required: true, message: '[用户头像]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 128, message: '最多128字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'username', label: '用户名称', value: ''
                    , rules: [
                        {required: true, message: '[用户名称]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 64, message: '最多64字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'phone', label: '电话号码', value: ''
                    , rules: [
                        {required: true, message: '[电话号码]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 16, message: '最多16字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'email', label: '邮箱', value: ''
                    , rules: [
                        {required: true, message: '[邮箱]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 128, message: '最多128字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'deptId', label: '用户部门', value: ''
                    , rules: [
                        {required: true, message: '[用户部门]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 32, message: '最多32字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'orgId', label: '机构号', value: ''
                    , rules: [
                        {required: true, message: '[机构号]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 32, message: '最多32字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'password', label: '密码', value: ''
                    , rules: [
                        {required: true, message: '[密码]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 32, message: '最多32字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'passwordSalt', label: '密码盐值', value: ''
                    , rules: [
                        {required: true, message: '[密码盐值]字段不允许为空 ', trigger: 'blur'},
                        {min: 0, max: 32, message: '最多32字符', trigger: 'blur'}
                    ]
                },
                {
                    name: 'disabled', label: '是否可用', value: ''
                },
                {
                    name: 'gmtCreate', label: '创建日期', value: ''
                },
                {
                    name: 'gmtModified', label: '修改日期', value: ''
                },
            ]
            // form-data end
        }
    },
    methods: {
        /**
         * 新增/编辑操作成功，关闭当前窗口
         *
         * @param ret 后台响应数据
         */
        callback: function (ret) {
            // 刷新表单列表
            this.onSucceed(ret);
            // 关闭弹窗
            this.$refs.dialog.close();
        }
    }
}
</script>
